<template>
  <div class="topbar">
    <van-nav-bar
      :title="title"
      :left-text="leftText"
      :right-text="rightText"
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickRight"
    >
    <template #right>
      <slot name="right">
      </slot>
    </template>
    </van-nav-bar>
  </div>
</template>

<script>
export default {
  name: 'TopBar',
  props: {
    title: {
      type: String,
      default:  '标题'
    },
    leftText: {
      type:String,
      default: '',
    },
    rightText: {
      type:String,
      default: ''
    }

  },
  methods: {
    onClickLeft() {
      this.$router.back();
    },
    onClickRight() {
      this.$emit('clickRight')
    }
  }

}
</script>

<style>

</style>